|
|
|
|
|
|
|
user has changed the colors on his or her computer to the same color, this change wont be visible. A better method is to fill in these text boxes with the word <Required> in italics. This way, the user will immediately see which values need to be filled in (see Figure 22.1). |
|
|
|
|
|
|
|
|
Figure 22.1
The Controls collection example. |
|
|
|
|
|
|
|
|
To accomplish this, you need to place the following code in the Click event of the cmdSave command button shown in Figure 22.1: |
|
|
|
 |
|
|
|
|
Private Sub cmdSave_Click()
If FormCheck() Then
Call FormSave
End If
End Sub |
|
|
|
|
|
|
|
|
The Click event in the cmdSave button calls the FormCheck() procedure to perform the validation on the Employee Information form. If the appropriate fields are not filled in, the FormCheck() function fills them in with <Required>. Heres the code for the FormCheck() function: |
|
|
|
 |
|
|
|
|
Private Function FormCheck() As Boolean
Dim boolFlag As Boolean
Dim ctlAny As Control
txtEmpID.Tag = ""
txtFirst.Tag = ""
txtLast.Tag = ""
If Trim$(txtEmpID) = "" Then
txtEmpID.Tag = "ERROR"
End If If Trim$(txtFirst) = "" Then
txtFirst.Tag = "ERROR" |
|
|
|
|
|